// Capitalist City - Business Simulation Game
// Copyright (C) 2011 Azlan Mukhtar
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef GAME_H
#define GAME_H
#define QT_SHAREDPOINTER_TRACK_POINTERS

#include "ui_mainwindow.h"
#include "ui_productui.h"
#include "ui_companyui.h"
#include <QtCore>
#include <QListWidget>
#include "store.h"
#include "simulation.h"
//#include "productsimulation.h"
#include "citysimulation.h"
#include "gamesettings.h"
#include "language.h"

class ProductUi;
class CompanyUi;
class StoreUi;
class ProductSimulation;
class Company;

extern QApplication *g_qApp;
extern CGameSettings *g_Setting;
extern CLanguage *g_Lang;


class Game : public QObject
{
    Q_OBJECT
public:
    Game(Ui::MainWindow *a_ui);
    ~Game();

    bool Run();
    void Initialize();
    void GameLoop();
    void SetupProductUi();

    void UpdateStatusBar();

public slots:
    void UpdateTimer();

private:
    Simulation*         m_sim;
    CitySimulation*     m_citySim;
    ProductSimulation*  m_productSim;
    QList<Company *>    m_companyList;
    quint64             m_tick;
    QTimer              m_timer;
    quint16             m_timer_interval;
    quint16             m_companyCounter;
    QDateTime           m_dateTime;
    bool                gamePaused;

    Ui::MainWindow*     mainUi;
    ProductUi*          m_productUi;
    CompanyUi*          m_companyUi;
    StoreUi*            m_storeUi;
    QList<ProductUi *>  m_productUiList;
    QVBoxLayout*        vLayout1;
    QHBoxLayout*        hLayout1;
    QListWidget*        listWidget;
    QVBoxLayout*        mainLayout;

private slots:
    void on_pbAddCompany_clicked();
    void on_actionProduct_triggered();
    void on_actionStore_triggered();
    void on_actionCompany_triggered();
    void on_actionStart_toggled(bool);
};

#endif // GAME_H
